<style>
    .footer-home{display: none;}
</style>
<header>
    <a href="index.php">
        <i class="iconfont icon-xialalan-copy"></i>
    </a>
    <span class="search_icon  iconfont icon-search"></span>
    <input class="fl search" type="text" placeholder="旅行社">
</header>
<div class="select_item flex_display margin_bot">
    <!--<select class="flex-1 sele <?php echo isset($_GET['order'])?'connect':'move'; ?> haha" name="order">
        <option value="">默认排序</option>
        <option value="price|asc" <?php echo $_GET['order']=='price|asc'?'selected':'' ?>>价格从低到高</option>
        <option value="price|desc" <?php echo $_GET['order']=='price|desc'?'selected':'' ?>>价格从高到低</option>
        <option value="sales|asc" <?php echo $_GET['order']=='sales|asc'?'selected':'' ?>>销量从低到高</option>
        <option value="sales|desc" <?php echo $_GET['order']=='sales|desc'?'selected':'' ?>>销量从高到低</option>
    </select>
    <select class="flex-1 sele <?php echo isset($_GET['area'])?'connect':'move'; ?> haha" name="area">
        <option value="">所有地区</option>
        <?php foreach($output['area_arr'] as $k=>$v){ ?>
            <option value="<?php echo $v['ir_city_id']; ?>" <?php echo $_GET['area']==$v['ir_city_id']?'selected':'' ?>><?php echo $v['name']; ?></option>
        <?php }?>
    </select>
    <select class="flex-1 sele <?php echo isset($_GET['cate_id'])?'connect':'move'; ?> haha" name="cate_id">
        <option value="">所有分类</option>
        <?php foreach($output['cate'] as $k=>$v){?>
            <option value="<?php echo $v['tc_id']; ?>" <?php echo $_GET['cate_id']==$v['tc_id']?'selected':'' ?>><?php echo $v['tc_name']; ?></option>
        <?php } ?>
    </select>-->

    <!--新的下拉标签-->

    <a class="flex-1 <?php echo isset($_GET['order'])?'color_blue':''; ?> haha" href="javascript:;">
        <?php if(isset($_GET['order'])): ?>
            <?php if($_GET['order']=='price|asc'){ ?>
                价格从低到高
            <?php }elseif($_GET['order']=='price|desc'){ ?>
                价格从高到低
            <?php }elseif($_GET['order']=='sales|asc'){ ?>
                销量从低到高
            <?php }elseif($_GET['order']=='sales|desc'){ ?>
                销量从高到低
            <?php }else{ ?>
                默认排序
            <?php } ?>
        <?php else: ?>
            默认排序
        <?php endif; ?>
        <i class="iconfont icon-xialalan"></i>
    </a>
    <ul id="order">
        <li id="">默认排序</li>
        <li id="price|asc">价格从低到高</li>
        <li id="price|desc">价格从高到低</li>
        <li id="sales|asc">销量从低到高</li>
        <li id="sales|desc">销量从高到低</li>
    </ul>

    <a class="flex-1 <?php echo isset($_GET['area'])?'color_blue':''; ?>  haha" href="javascript:;">
        <?php if(isset($_GET['area'])): ?>
            <?php if($_GET['area']>0): ?>
                <?php foreach($output['area_arr'] as$k=>$v): ?>
                    <span style="<?php if($_GET['area']!=$v['ir_area_id']){echo 'display: none;'; }; ?>"><?php echo $v['name']; ?></span>
                <?php endforeach ?>
            <?php else: ?>
                全部地区
            <?php endif; ?>
        <?php else: ?>
            地区筛选
        <?php endif; ?>
        <i class="iconfont icon-xialalan"></i>
    </a>
    <ul id="area">
        <li>全部城市</li>
        <?php foreach($output['area_arr'] as$k=>$v): ?>
            <li id="<?php echo $v['ir_area_id']; ?>"><?php echo $v['name']; ?></li>
        <?php endforeach ?>
    </ul>

    <a class="flex-1 <?php echo isset($_GET['cate_id'])?'color_blue':''; ?> haha" href="javascript:;">
        <?php if(isset($_GET['cate_id'])): ?>
            <?php if($_GET['cate_id']>0): ?>
                <?php foreach($output['cate'] as$k=>$v): ?>
                    <span style="<?php if($_GET['cate_id']!=$v['tc_id']){echo 'display: none;'; }; ?>"><?php echo $v['tc_name']; ?></span>
                <?php endforeach ?>
            <?php else: ?>
                全部分类
            <?php endif; ?>
        <?php else: ?>
            全部分类
        <?php endif; ?>
        <i class="iconfont icon-xialalan"></i>
    </a>

    <ul id="cate_id">
        <li id="">全部分类</li>
        <?php foreach($output['cate'] as$k=>$v): ?>
            <li id="<?php echo $v['tc_id']; ?>"><?php echo $v['tc_name']; ?></li>
        <?php endforeach ?>
    </ul>
            <!--下拉标签结束-->
</div>
<div class="order-submit">
    <ul class="food_list">
        <?php if( $output['list']): ?>
            <?php foreach($output['list']  as  $key =>$item): ?>
        <li >
            <a class="flex_display" href="index.php?act=itinerary&op=info&irid=<?php echo $item['id']; ?>">
            <div class="food_img flex-0"><img src="<?php echo $item['ir_thumb']; ?>"></div>
            <div class="food_info flex-1">
                <h1 class="p-2"><?php echo $item['ir_title']; ?></h1>
                <h5 class="p-1"><?php echo $item['label']; ?></h5>
                <div class="color_red food_price">￥<?php echo $item['price']; ?><span class="">已售<b class="color_red"><?php echo $item['sales']; ?></b>件</span></div>
            </div>
            </a>
        </li>
             <?php endforeach; ?>
        <?php endif;?>
    </ul>
</div>
<!--加载更多-->
<div class="load" style="text-align: center;display: none;">
    <div class="loading" style="text-align: center;">正在加载中....</div>
</div>
<script>

    //select 搜索
    $(".sele").change(function(){
        var name = $(this).attr('name')
        var val = $(this).val();
        window.location.href='index.php?act=itinerary&'+name+'='+val;
    });

    //ajax加载分页

    var allNum = <?php echo $output['TotalNum']; ?>,
        allPage = <?php echo $output['TotalPage']; ?>,
        curPage = 1;

    var is_scroll = false;
    $(window).scroll(function () {
        is_scroll = true;
        //已经滚动到上面的页面高度
        var scrollTop = $(this).scrollTop();
        //页面高度
        var scrollHeight = $(document).height();
        //浏览器窗口高度
        var windowHeight = $(this).height();
        //此处是滚动条到底部时候触发的事件，在这里写要加载的数据，或者是拉动滚动条的操作
        if (scrollTop + windowHeight == scrollHeight) {
            $('.load').show();
            loadpage();
        }
    });
    function loadpage(){
        if(!is_scroll){
            return;
        }
        if (curPage < allPage) {
            curPage += 1;
        } else {
            $('.load').text('没有更多内容了').show();
            return;
        }
        $.get(location.href, {isajax:1,curpage:curPage},function(data){
            if(data){
                $(".food_list").append(data);
                $('.load').hide();
            }
        });
    }

    //下拉选项
        $(".select_item a").click(function () {
            $(this).addClass("color_blue").siblings().removeClass("color_blue");
            $(this).next("ul").slideToggle();
            $(this).next("ul").siblings("ul").css("display","none");

        });

        //文本传值
        $(".select_item li").click(function () {
            //console.log($(this).text());
            //console.log($(this).parent().prev().text());
            var i='<i class="iconfont icon-xialalan"></i>';
            $(this).parent().prev().html($(this).html()+i);
            $(this).parent("ul").slideUp();
            var name = $(this).parents('ul').attr('id');
            var val  = $(this).attr('id');
            window.location.href='index.php?act=itinerary&'+name+'='+val;
        });

</script>